Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy Context Propagation & useContextSelector hook #3

Closed
wants to merge 2 commits into from

Conversation

gnoff
Copy link
Owner

@gnoff gnoff commented Jun 12, 2019

Will end up breaking into separate RFCs and PRs

For now

Lazy Propagation Algorithm: attempts to take advantage of already scheduled work to avoid walking the fiber tree except when necessary (on bailouts that don't go deeper for work on children)

useContextSelector hook: adds a hook that is a modified context reader. it will only schedule work on it's host fiber when the selector value has changed. This hook is intended to be used with the new propagation scheme because it otherwise has numerous problems with selectors running too often / too early.

@gnoff gnoff force-pushed the context-selectors branch 2 times, most recently from 0be9bfa to c8343ac Compare June 14, 2019 21:49
@@ -1049,6 +1049,142 @@ describe('ReactNewContext', () => {
span(2),
]);
});
describe('stress test', () => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not suggesting we keep this kind of test in place, but wanted to explore implications of this change in a more demanding environment than most tests produce

expect(Scheduler).toFlushAndYield(['A: 4', 'B: 4', 'C: 4']);
}
});
it('non-context stress test', () => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tests doesn't use context but acts as a comparable of non-context rendering to see if lazy context adds overhead to work in general

@@ -186,6 +253,198 @@ function scheduleWorkOnParentPath(
}
}

export function checkContextDependencies(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much of the new code in this file could be 'unified' with the existing propagation function to save on LoC but it would make the actual algorithm a little harder to see so it is duplicated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant